//
//  OrderSubListSectionFooterView.m
//  BaseProject
//
//  Created by 王洋 on 2020/6/16.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "OrderSubListSectionFooterView.h"

@interface OrderSubListSectionFooterView ()


//@property (nonatomic, strong) 

@end

@implementation OrderSubListSectionFooterView

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.firstBtn.hidden = YES;
    self.secondBtn.hidden = YES;
}


- (void)fillFooterWithModel:(OrderListSupplierModel *)model {

    self.firstBtn.hidden = YES;
    self.secondBtn.hidden = YES;
    
    self.firstBtn.tag = -1;
    self.secondBtn.tag = -2;
    
    for (int i = 0; i < model.footerBtnList.count; i++) {
        
        if (i == 0) {
            self.firstBtn.hidden = NO;
            self.secondBtn.hidden = YES;

            [self.firstBtn setTitle:model.footerBtnList[i].btnTitle forState:UIControlStateNormal];
            self.firstBtn.tag = model.footerBtnList[i].btnAction;
            if (model.footerBtnList[i].btnColorType == 0) {
                [self.firstBtn setTitleColor:UIColorHex(0x999999) forState:UIControlStateNormal];
                [self.firstBtn pp_clipCorners:UIRectCornerAllCorners radius:15 border:1 color:UIColorHex(0x999999)];
            } else {
                [self.firstBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
                [self.firstBtn pp_clipCorners:UIRectCornerAllCorners radius:15 border:1 color:[UIColor redColor]];
            }

        }
        
        if (i == 1) {
            
            self.firstBtn.hidden = NO;
            self.secondBtn.hidden = NO;

            [self.secondBtn setTitle:model.footerBtnList[i].btnTitle forState:UIControlStateNormal];
            self.secondBtn.tag = model.footerBtnList[i].btnAction;

            if (model.footerBtnList[i].btnColorType == 0) {
                [self.secondBtn setTitleColor:UIColorHex(0x999999) forState:UIControlStateNormal];
                [self.secondBtn pp_clipCorners:UIRectCornerAllCorners radius:15 border:1 color:UIColorHex(0x999999)];
            } else {
                [self.secondBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
                [self.secondBtn pp_clipCorners:UIRectCornerAllCorners radius:15 border:1 color:[UIColor redColor]];
            }
        }
    }
}


- (IBAction)firstBtnAction:(id)sender {
    
    UIButton *button = (UIButton *)sender;
    if (self.OrderSubListSectionFooterBlock) {
        self.OrderSubListSectionFooterBlock((OrderSubListSectionFooterViewAction)button.tag);
    }
}

- (IBAction)secondBtnAction:(id)sender {
    
    UIButton *button = (UIButton *)sender;
    if (self.OrderSubListSectionFooterBlock) {
        self.OrderSubListSectionFooterBlock((OrderSubListSectionFooterViewAction)button.tag);
    }
}








@end
